package com.compass.doctor.ui.mine.adapter

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.compass.doctor.R
import com.compass.doctor.databinding.LayoutInquiryRecordItemBinding
import com.compass.doctor.databinding.LayoutWalletDetailItemBinding
import com.compass.doctor.utils.StringUtils
import com.compass.framework.adapter.BaseBindViewHolder
import com.compass.framework.adapter.BaseRecyclerViewAdapter
import com.compass.framework.model.ArticleInfo
import com.compass.framework.model.WalletDetail
import com.compass.framework.utils.getColorFromResource

/**
 * Description： 钱包明细adapter
 * Date:2023/12/25 22:08
 */
class WalletDetailAdapter : BaseRecyclerViewAdapter<WalletDetail, LayoutWalletDetailItemBinding>() {


    override fun getViewBinding(
        layoutInflater: LayoutInflater,
        parent: ViewGroup,
        viewType: Int
    ): LayoutWalletDetailItemBinding {
        return LayoutWalletDetailItemBinding.inflate(layoutInflater, parent, false)
    }

    override fun onBindDefViewHolder(
        holder: BaseBindViewHolder<LayoutWalletDetailItemBinding>,
        item: WalletDetail?,
        position: Int
    ) {
        if (item == null) return
        holder.binding.apply {
            tvTitle.text = item.title
            tvCreateTime.text=StringUtils.conversionTime(item.createTime)
            tvChangePrice.text=item.changePrice.toString()

            if (item.changePrice>0) tvChangePrice.setTextColor(getColorFromResource(R.color.color_2e344a)) else tvChangePrice.setTextColor(getColorFromResource(R.color.color_ff8e12))



            if (position==getData().size-1) viewLine.visibility= View.GONE else viewLine.visibility= View.VISIBLE
        }
    }
}